package com.avengers.common.bean.enums;

import java.util.ArrayList;
import java.util.List;

/**
 * @author zhangnan
 * @since 2025/2/26 16:52
 **/
public enum DomainBuySuffix {
    COM(".com", 1),
    NET(".net", 2),
    CN(".cn", 3),
    COM_CN(".com.cn", 4),
    NET_CN(".net.cn", 5),
    ORG_CN(".org.cn", 6),
    CC(".cc", 7),
    TV(".tv", 8),
    CHINESE(".中国", 9),
    OTHER("其他", 99);

    public String suffix;
    public int value;

    DomainBuySuffix(String suffix, int value) {
        this.suffix = suffix;
        this.value = value;
    }

    public static Integer ofSuffix(String suffix) {
        for (DomainBuySuffix buySuffix : values()) {
            if (buySuffix.suffix.equalsIgnoreCase(suffix)) {
                return buySuffix.value;
            }
        }
        return OTHER.value;
    }

    public static List<Integer> transferSuffix(List<String> suffixList) {
        List<Integer> valueList = new ArrayList<>();
        for (String suffix : suffixList) {
            for (DomainBuySuffix buySuffix : values()) {
                if (buySuffix.suffix.equalsIgnoreCase(suffix)) {
                    valueList.add(buySuffix.value);
                }
            }
        }
        return valueList;
    }
}